Skip to content

feat(mac): a GPU keep-alive switch on the settings panel's Display page - #2049

Merged
ly05010419 merged 1 commit into
ly05010419:mainfrom
Enokine:feat/keepalive-switch
Nov 10, 2026
Merged

ly05010419 merged 1 commit into
ly05010419:mainfrom
Enokine:feat/keepalive-switch

Conversation

@Enokine

@Enokine Enokine commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Why

The GPU keep-alive runs short spin kernels between frames so the GPU never drops its clock. That helps a Mac whose GPU slows down while it waits for the next frame: the measurement in keepalive_start was on an M4, where the frame's GPU work ran about 25 % faster with it.

On a stronger Mac, the game's own work keeps the clock up anyway. There the spinner adds heat and power use but no frames. On a MacBook Pro M4 Max (36 GB) running Breath of the Wild 1.9.0 at 1080p + MetalFX with 60+60 interpolation, I measured:

Keep-alive GPU busy (ioreg "Device Utilization %")
on about 90 %
off about 63 %

These numbers come from a 2-minute recording with the switch flipped back and forth in the same spot. Each flip changed the load within one second. With the keep-alive off I lost no frames, the laptop ran noticeably cooler, and over several days of play the game felt as smooth as with it on, or smoother. Until now the only way to turn it off was TOTK_GPU_KEEPALIVE=0 in the environment, which most players never set.

What

  • Settings panel → Display: a new switch, "GPU keep-alive (holds the clock up; hotter, more power)", below frame interpolation.
    • It takes effect at once. When switched off, the spinner thread only sleeps. When switched on, it starts if it has not started yet.
    • The choice is saved in gpu-keepalive.txt in the folder above the game's, shared by both games like fps-graph.txt, and is read before the guest starts.
    • TOTK_GPU_KEEPALIVE still decides first. When it is set, the row is greyed out and shows its value.
  • Defaults are unchanged: on on the Mac, off on iPhone and iPad.
  • nvn_mtl.m: new dm_gfx_keepalive, dm_gfx_keepalive_locked, dm_gfx_keepalive_start and dm_gfx_keepalive_set, in the same pattern as dm_gfx_aniso_*. The spinner loop now checks the switch.
  • tests/settings_panel_probe.m: stubs for the four new functions.

Testing

  • Played: Breath of the Wild 1.9.0 + both DLC on the M4 Max, macOS 27.2.
    • Flipping the switch in play logs GPU keep-alive: on/off from the settings panel.
    • The spinner's per-window stats line (GPU 保活 至帧 …) appears only while the switch is on.
    • GPU load follows the switch, as in the table above.
  • I played with the same change on my own build. It is based on an older main (9fe3fdc) and defaults to off. This PR keeps upstream's default (on on the Mac). I have not played a build of this exact branch.
  • Compiled: nvn_mtl.m compiles for the Mac and iOS, for both TotK and BotW 1.9.0, with clang -fsyntax-only.
  • Unit tests: I ran tests.test_settings_panel, tests.test_frame_lock, tests.test_botw_effects and tests.test_state_report.
    • The probe's row counts are updated: one more row in all, and 7 on the Display page.
    • 5 subtests of test_current_modes_and_refresh still fail, but they fail the same way on main (d237386) without this change:
      • Four abort with NSRangeException: -[__NSSingleObjectArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0] at the same place in main.
      • One fails the Update tab assertion in update_probe.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AHfZGAk8x4FhGRe2CKhfVf

The keep-alive's spin kernels hold the GPU clock up between frames. On a Mac whose GPU keeps its clock with the game's own
work they add heat and power but no frame (an M4 Max at 60+60 interpolation: ~90 % GPU busy with them, ~63 % without, the
same frames), and only TOTK_GPU_KEEPALIVE=0 turned them off. The switch turns them on or off at once
(dm_gfx_keepalive_set; a thread switched off only sleeps) and is saved in gpu-keepalive.txt above the game's folder, shared
by both games. TOTK_GPU_KEEPALIVE decides first and greys the row out. Defaults unchanged: on on the Mac, off on iOS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AHfZGAk8x4FhGRe2CKhfVf
@ly05010419
ly05010419 merged commit 6b1f707 into ly05010419:main Nov 10, 2026
1 check passed
ly05010419 added a commit that referenced this pull request Nov 10, 2026
…ctions (after PR #2049)

settings_panel.h now calls dm_gfx_keepalive_start and its row's getters; the fixture text_keyboard includes had only the
anisotropy stubs, so its three tests failed to link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ly05010419

Copy link
Copy Markdown
Owner

Merged and pushed — thank you. One follow-up after it (45f1f48): games/totk/tests/command_q/probe.m, the no-game frontend fixture that test_text_keyboard includes, had no keep-alive stubs, so its three tests failed to link (_dm_gfx_keepalive_start); it now has the four stubs, next to the anisotropy ones. Not yet flipped in a game here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants